
package com.thinkgem.jeesite.common.component.redis.utils;

import java.util.Arrays;
import java.util.HashMap;
import java.util.List;

import redis.clients.jedis.Jedis;

import com.thinkgem.jeesite.common.component.redis.shell.common.RdsLink;


/** 
 * 放置rds的工具类元素操作
 * 主要提供通用的处理流程:vo或event对象存储,关键字检索等
 */
public class RdsUtils {

	public static String getSdbModelProto() {
    	return sdbModelProto;
    }

	public static void setSdbModelProto(String sdbModelProto) {
    	RdsUtils.sdbModelProto = sdbModelProto;
    }

	public static String[] getAdbModelProto() {
    	return adbModelProto;
    }

	public static void setAdbModelProto(String[] adbModelProto) {
    	RdsUtils.adbModelProto = adbModelProto;
    }

	public static List<String> getLdbModelProto() {
    	return ldbModelProto;
    }

	public static void setLdbModelProto(List<String> ldbModelProto) {
    	RdsUtils.ldbModelProto = ldbModelProto;
    }

	/******************针对对象数据的增删改查和条件检索************************/

	/**********common************/

	public static String getModelInfo(HashMap<String, String> voProtoMap,edbModelProto eModelProto){
		if(voProtoMap != null && !voProtoMap.isEmpty()){
			return voProtoMap.get(eModelProto.toString());
		} else {
			return null;
		}
	}

	public static void clean(Jedis jds){
		jds.flushDB();
	}

	public static boolean isInMulti(Jedis jds){
		return jds.getClient().isInMulti();
	}

	/***********************属性区域************************/

	public static enum edbModelProto{
		model,
		extend,
		fields,
		pks,
		methods,
		searchfields,
		};
	public static String sdbModelProto = RdsLink.getClassFields(edbModelProto.class);
	public static String[] adbModelProto = sdbModelProto.split(",");
	public static List<String> ldbModelProto = Arrays.asList(adbModelProto);

}
